package com.kiln.juxingqs.ui

import androidx.lifecycle.Observer
import client.global.commlib.toast.toast
import com.kiln.juxingqs.BaseMiddleActivity
import com.kiln.juxingqs.R
import com.kiln.juxingqs.databinding.ActivitySetbank3CodeBinding
import com.kiln.juxingqs.ui.vm.SetBank3ViewModel

/**
 * 绑定银行卡验证
 */
class Bank3CodeActivity :
    BaseMiddleActivity<SetBank3ViewModel, ActivitySetbank3CodeBinding>() {

    var applyId: String? = null
    var payment_id: String? = null

    override fun getLayout(): Int {
        return R.layout.activity_setbank3_code
    }

    override fun initViewModel(): SetBank3ViewModel = createViewModel()

    override fun initView() {
        binding.event = this
        binding.vm = viewModel

        applyId = intent.getStringExtra("apply_id")
        payment_id = intent.getStringExtra("payment_id")
//        binding.applyId = applyId
    }

    override fun initData() {

    }

    override fun observerUI() {
//        viewModel.callBindCode.observe(this, Observer {
//            it?.apply {
//                if (isSuccess) {
//                    toast("操作成功")
//                    finish()
//                }
//            }
//        })
        viewModel.codeRet.observe(this, Observer {
            it?.apply {
                if (isSuccess) {
                    toast("操作成功")
                    finish()
                }
            }
        })
    }


    fun ok() {
//        if (applyId != null) {
//
//        } else {
//
//        }

        applyId?.let {
            viewModel.verifyPhone(it)
        }
        payment_id?.let {
            viewModel.confirmPay(it)
        }

//        if (viewModel.num.value == null || viewModel.txType.value!! < 0) {//
//            toast("所有不得为空")
//            return
//        }
//

    }


}